﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using Cloak.NUnit;
using Cloak.Reflection;
using NUnit.Framework;

namespace Cloak.Linq
{
	public class CreateTypedFunc3Parameters : Behavior
	{
		private LambdaExpression _lambda;
		private Expression<Func<string, bool, char, int>> _typedLambda;

		protected override void Given()
		{
			_lambda = Expression.Lambda(
				Expression.Constant(0),
				Expression.Parameter(typeof(string)),
				Expression.Parameter(typeof(bool)),
				Expression.Parameter(typeof(char)));
		}

		protected override void When()
		{
			_typedLambda = _lambda.AsFunc<string, bool, char, int>();
		}

		[Then]
		public void BodiesAreEqual()
		{
			Assert.AreEqual(_lambda.Body, _typedLambda.Body);
		}

		[Then]
		public void ParametersAreEqual()
		{
			Assert.IsTrue(_lambda.Parameters.SequenceEqual(_typedLambda.Parameters));
		}
	}
}